# coding:utf-8
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from util.get_by_local import GetByLocal
from base.base_driver import BaseDriver
class LoginPage:
    def __init__(self, i):
        base_driver = BaseDriver()
        self.driver = base_driver.android_driver(i)
        self.get_by_local = GetByLocal(self.driver)
    #获取登录页面的所有元素信息
    def get_tologin_element(self):
        # 跳转登录
        return self.get_by_local.get_element('to_login')
    def get_username_element(self):
        return self.get_by_local.get_element('username') # 获取手机号码/邮箱输入框element
    def get_next_element(self):
        return self.get_by_local.get_element('next_button') # 获取下一步按钮element
    def get_back_element(self):
        return self.get_by_local.get_element('back_button')# 获取返回按钮element
    def get_password_element(self):
        return self.get_by_local.get_element('password')# 获取密码框element
    def get_login_element(self):
        return self.get_by_local.get_element('login_button')# 获取登录按钮element
    def get_forgetpassw_element(self):
        return self.get_by_local.get_element('forget_password')# 获取登录按钮element
    def get_phone_login_element(self):
        return self.get_by_local.get_element('phone_login')# 获取登录按钮element
    def get_email_login_element(self):
        return self.get_by_local.get_element('email_login')# 获取登录按钮element
    def get_tost_element(self,message):
        tost_element = ("xpath", "//*[contains(@text,"+message+")]")
        return WebDriverWait(self.driver, 10, 0.1).until(EC.presence_of_element_located(tost_element))